package cz.muni.fi.pa165.sme.web.converters;

import cz.muni.fi.pa165.sme.api.to.BurnedCaloriesTO;
import cz.muni.fi.pa165.sme.web.fo.BurnedCaloriesFO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;

/**
 * @author jirankova
 */
public class BurnedCaloriesFO2BurnedCaloriesTOConverter implements Converter<BurnedCaloriesFO, BurnedCaloriesTO> {

	@Autowired
	private SportActivityFO2SportActivityTOConverter converter;

	@Override
	public BurnedCaloriesTO convert(final BurnedCaloriesFO source) {
		if (source == null) {
			return null;
		}

		final BurnedCaloriesTO target = new BurnedCaloriesTO();

		target.setSpeed(source.getSpeed());
		target.setCalories(source.getCalories());
		target.setId(source.getId());
		target.setSportActivity(converter.convert(source.getSportActivity()));
		target.setWeight(source.getWeight());

		return target;
	}
}
